package org.gordonframework.site.forms.elements.skins {
	import org.gordonframework.core.collection.GItemWrapper;
	import org.gordonframework.core.collection.GSet;		

	/**
	 * @author eriarv
	 */
	public class GElementSkinFactory {
		
		private static var instance : GElementSkinFactory = null;
		private var skins : GSet;
		
		public function GElementSkinFactory( caller : String ) {
			if ( caller != "don't do it") {
				throw new Error( "Please use static getInstance()");
			}
			
			skins = new GSet();
			
		}
		
		public static function getInstance() : GElementSkinFactory {
			if ( instance == null ) {
				instance = new GElementSkinFactory( "don't do it");
			}
			
			return instance;
		}

		public function setSkinForType( type : String, skinClass : Class ) : Boolean {
			return skins.addAndReplace(new GItemWrapper(type, skinClass ) );
		}

		public function getSkinClassForType( type : String ) : Class {
			return (skins.getItemById(type) as GItemWrapper).object as Class;
		}
		
	}
}
